package scalab.caches.cdp

import scalab.core.{ChangeDetectionPolicy, Resource}
import scalab.core.dependencies.Dependency
import scalab.utils.Digest
import java.security.MessageDigest

/**
*	Defines a change detection policy based on digests.
*/
trait DigestCDP extends ChangeDetectionPolicy{
	def hashDependency(md: MessageDigest, dep: Dependency) = Digest.update(md, dep)
	def hashResource(md: MessageDigest, res: Resource){
		val present = res.exists
		if(present)Digest.updateWithContent(md, res)
		Digest.update(md, present.toString)
	}
}
